/**
 * Copyright (C) 2010 Hamburg Sud
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hamburgsud.log4testing.core;

import java.util.Collection;
import java.util.Hashtable;

import com.hamburgsud.log4testing.core.data.TestCase;
import com.hamburgsud.log4testing.core.data.TestSuite;

public class TestLogger {

	private static Hashtable<String, TestSuite> testSuites;
	private static Hashtable<String, TestCase> testCases;

	static {
		testSuites = new Hashtable<String, TestSuite>(50);
		testCases = new Hashtable<String, TestCase>(500);
	}

	public static TestSuite getTestSuite(final String name) {
		TestSuite testSuite = testSuites.get(name);
		if (testSuite == null) {
			testSuite = new TestSuite(name);
			testSuites.put(name, testSuite);
		}
		return testSuite;
	}

	public static TestSuite getTestSuite(final Class<?> c) {
		return getTestSuite(c.getName());
	}

	public static TestSuite getTestSuite(final Object object) {
		return getTestSuite(object.getClass());
	}

	public static Collection<TestSuite> getTestSuites() {
		return testSuites.values();
	}

	public static TestCase getTestCase(final String name) {
		TestCase testCase = testCases.get(name);
		if (testCase == null) {
			testCase = new TestCase(name);
			testCases.put(name, testCase);
		}
		return testCase;
	}

	public static TestCase getTestCase(final Class<?> c) {
		return getTestCase(c.getName());
	}

	public static Collection<TestCase> getTestCases() {
		return testCases.values();
	}

	public static TestCase getTestCase(final Object object) {
		return getTestCase(object.getClass());
	}

}
